// 引入Express对象
var express = require('express');
var xmlparser = require('express-xml-bodyparser');
var router = express.Router();

// 引入Token验证中间件
const verifyMiddleware = appRequire('routes/middleware/verify');

const wxQrcode = appRequire('controllers/wx/wxQrcode');
const wxPay = appRequire('controllers/wx/wxPay');
const wxNotice = appRequire('controllers/wx/wxNotice');
const wxOutMoney = appRequire('controllers/wx/tixian/wxOutMoney');
const wxVipPay = appRequire('controllers/wx/wxVipPay');
const wxVipNotice = appRequire('controllers/wx/wxVipNotice');

const wxGroup = appRequire('controllers/wx/wxGroup');
const wxFWH = appRequire('controllers/wxFWH/wechat');

// 定义登录路由，POST请求
router.post('/wxQrcode', wxQrcode.wxQrcode);
router.post('/wxPay', wxPay.wxPay);
router.post('/wxH5Pay', wxPay.wxH5Pay);
router.post('/checkOrder', wxPay.checkOrder); //支付成功，验证账单状态
router.post('/wxOutMoney', verifyMiddleware.verifyToken, wxOutMoney.wxOutMoney); //提现
router.post('/wxNotice', xmlparser({ trim: false, explicitArray: false }), wxNotice); //支付成功，验证是否来自微信

router.post('/wxVipPay', wxVipPay.wxPay);
router.post('/wxVipH5Pay', wxVipPay.wxH5Pay);

router.post('/wxVipNotice', xmlparser({ trim: false, explicitArray: false }), wxVipNotice); //支付成功，验证是否来自微信

router.post('/wxGroup/list', wxGroup.list);
router.post('/wxGroup/save', wxGroup.save);
router.post('/wxGroup/remove', wxGroup.destroy);
router.post('/wxGroup/detail', wxGroup.detail);

router.all('/wxFWHWebAuth', wxFWH.webAuth);
router.post('/getConfigData', wxFWH.getConfigData);

// 导出路由，供app.js文件调用
module.exports = router;
